<!DOCTYPE html>
<html>

<head>
    <title>{$Think.config.app_name}</title>
    {include file="public/head_frame"/}
</head>

<body class="layui-layout-body">
    <div id="LAY_app" class="layadmin-tabspage-none">
        <div class="root_box" id="LAY_app_body" v-cloak>
            <form class="layui-form" action="" lay-filter="example">
                <div class="layui-form-item">
                    <label class="layui-form-label">节点名称</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点名称" class="layui-input" v-model="item.node_title">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">节点描述</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点描述" class="layui-input" v-model="item.node_desc">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">节点图标</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点图标" class="layui-input" v-model="item.node_icon">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">模块</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点模块" class="layui-input" v-model="item.node_module">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">控制器</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点控制器" class="layui-input" v-model="item.node_controller">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">方法</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入节点方法" class="layui-input" v-model="item.node_action">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">父节点</label>
                    <div class="layui-input-block">
                        <select lay-ignore class="layui-input" name="node_pid" v-model="item.node_pid">
                            <option value="0">根节点</option>
                            <option v-for="pitem in plist" :value="pitem.node_id" :label="['　'+pitem.node_title]">
                            </option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单显示</label>
                    <div class="layui-input-block">
                        <select lay-ignore class="layui-input" name="node_pid" v-model="item.node_show">
                            <option value="1">显示</option>
                            <option value="0">不显示</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单排序</label>
                    <div class="layui-input-block">
                        <input type="text" placeholder="请输入菜单排序" class="layui-input" v-model="item.node_order">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" @click="submit">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
{include file="public/foot_frame"/}
<script>
    var app = new Vue({
        el: ".root_box",
        data: {
            item: {},
            plist: [],
        },
        created: function () {
            $.post("/api/node/lists", Object.assign({
                node_pid: 0
            }, PostCommon), function (data, status) {
                _hideLoading();
                if (data.code != 200) {
                    _alert(data.msg);
                } else {
                    app.plist = data.data.data;
                    app.item.node_pid = 0;
                    app.item.node_show = 1;
                    app.item.node_order = 0;
                }
            });
        },
        methods: {
            submit: function () {
                _loading();
                $.post("/api/node/add", Object.assign(this.item, PostCommon), function (data, status) {
                    _hideLoading();
                    if (data.code != 200) {
                        if (data.url) {
                            location.replace(data.url);
                        }
                        _alert(data.msg);
                    } else {
                        parent.closewindow();
                    }
                });
            },
        }
    });
</script>

</html>